//
//  HexCellCoordinate.h
//  DiceWar
//
//  Created by xiaofeng on 21/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#ifndef CLASSES_GAME_GAMEPLAY_HexCellCoordinate_H_
#define CLASSES_GAME_GAMEPLAY_HexCellCoordinate_H_

#include <vector>

class HexCellCoordinate
{
public:
    HexCellCoordinate(): m_x(0), m_y(0) {}
    HexCellCoordinate(int xValue, int yValue): m_x(xValue), m_y(yValue) {}
    ~HexCellCoordinate() {}
    
    HexCellCoordinate(const HexCellCoordinate& other): m_x(other.m_x), m_y(other.m_y) {}
    HexCellCoordinate& operator=(const HexCellCoordinate& other)
    {
        m_x = other.m_x;
        m_y = other.m_y;
        return *this;
    }
    
public:
    static bool isValid(int coordinateX, int coordinateY);
    
    bool isNextTo(const HexCellCoordinate& other);
    bool operator==(const HexCellCoordinate& other) const;
    
    void setCoordinate(int x, int y);
    void setToInvalid();
    
    int getX() const { return m_x; }
    void setX(int x) { m_x = x; }
    
    int getY() const { return m_y; }
    void setY(int y) { m_y = y; }
    
    bool isValid() const;
    
    /** to get the cell coordinate of the neighbor down to this cell
     */
    HexCellCoordinate getDownNeighbor() const;

    /** to get the cell coordinate of the neighbor up to this cell
     */
    HexCellCoordinate getUpNeighbor() const;
    
    /** to get the cell coordinate of the neighbor down left to this cell
     */
    HexCellCoordinate getDownLeftNeighbor() const;
    
    /** to get the cell coordinate of the neighbor down right to this cell
     */
    HexCellCoordinate getDownRightNeighbor() const;
    
    /** to get the cell coordinate of the neighbor up left to this cell
     */
    HexCellCoordinate getUpLeftNeighbor() const;
    
    /** to get the cell coordinate of the neighbor up to this cell
     */
    HexCellCoordinate getUpRightNeighbor() const;
    
    /** to get all the neighbors of the cell and return it in the vector
     */
    void getAllNeighbors(std::vector<HexCellCoordinate>& neighbors) const;
    
private:
    int m_x;
    int m_y;
};

#endif //CLASSES_GAME_GAMEPLAY_HexCellCoordinate_H_
